package logging;

import java.io.*;
import java.util.Date;

public class Log {

	final static int SEVERE = 0;
	final static int WARNING = 1;
	final static int INFO = 2;
	final static int THRESHOLDVALUE = 1;

	public static void println(Class<?> klassenName, String methodenName,
			int level, String s, boolean console) throws IOException {
		String temp = "";
		Date dt = new Date();
		String date;
		String klasse = klassenName.getName();
		date = dt.toString();

		if (level <= THRESHOLDVALUE) {
			temp = date + "  Wir sind hier -->" + klasse + " " + methodenName
					+ " " + s;
			
			if (console) {
				System.out.println(temp);
				PrintWriter out;
				try {
					out = new PrintWriter(new BufferedWriter(new FileWriter(
							"logging.txt", true)));
					// out.append(temp);
					out.println(temp + "\n");
					out.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			} else {
				PrintWriter out;
				try {
					out = new PrintWriter(new BufferedWriter(new FileWriter(
							"logging.txt", true)));
					// out.append(temp);
					out.println(temp + "\n");
					out.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}
		}

	}

}
